home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue47 / Clinic / ActiveX / IEBrowsU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-01-18  |  4.1 KB  |  159 lines

  1. unit IEBrowsU;
  2.  
  3. {$ifdef Windows}
  4.   'This is for Win32 compilers only'
  5. {$endif}
  6. {$ifdef Ver90} { Delphi 2.0x }
  7.   {$define DelphiLessThan3}
  8.   {$define DelphiLessThan4}
  9. {$endif}
  10. {$ifdef Ver93} { C++ Builder 1.0x }
  11.   {$define DelphiLessThan3}
  12.   {$define DelphiLessThan4}
  13. {$endif}
  14. {$ifdef Ver100} { Delphi 3.0x }
  15.   {$define DelphiLessThan4}
  16. {$endif}
  17. {$ifdef Ver110} { C++ Builder 3.0x }
  18.   {$define DelphiLessThan4}
  19. {$endif}
  20.  
  21. interface
  22.  
  23. uses
  24. {$ifdef DelphiLessThan3}
  25.   ShDocVw,
  26. {$else}
  27.   SHDocVw_TLB,
  28. {$endif}
  29.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  30.   StdCtrls, ExtCtrls;
  31.  
  32. type
  33.   TForm1 = class(TForm)
  34.     btnAbout: TButton;
  35.     btnEasterEgg: TButton;
  36.     Panel1: TPanel;
  37.     btnWin98: TButton;
  38.     edtURL: TEdit;
  39.     Label1: TLabel;
  40.     btnBrowse: TButton;
  41.     procedure btnBrowseClick(Sender: TObject);
  42.     procedure btnAboutClick(Sender: TObject);
  43.     procedure btnEasterEggClick(Sender: TObject);
  44.     procedure btnWin98Click(Sender: TObject);
  45.   private
  46.     { Private declarations }
  47.   public
  48.     { Public declarations }
  49.   end;
  50.  
  51. var
  52.   Form1: TForm1;
  53.  
  54. implementation
  55.  
  56. {$R *.DFM}
  57.  
  58. {$ifdef DelphiLessThan4}
  59. var
  60.   EmptyParam: {$ifdef DelphiLessThan3}Variant{$else}OleVariant{$endif};
  61. {$endif}
  62.  
  63. const
  64.   WB: TWebBrowser = nil;
  65.  
  66. procedure TForm1.btnBrowseClick(Sender: TObject);
  67. begin
  68.   if not Assigned(WB) then
  69.   begin
  70.     WB := TWebBrowser.Create(Self);
  71.     TControl(WB).Parent := Panel1;
  72.     WB.Align := alClient;
  73.   end;
  74.   WB.Navigate(edtURL.Text, EmptyParam, EmptyParam, EmptyParam, EmptyParam)
  75. end;
  76.  
  77. procedure TForm1.btnAboutClick(Sender: TObject);
  78. begin
  79.   if not Assigned(WB) then
  80.   begin
  81.     WB := TWebBrowser.Create(Self);
  82.     TControl(WB).Parent := Panel1;
  83.     WB.Align := alClient;
  84.   end;
  85.   WB.Navigate('res://shdocvw.dll/about.dlg',
  86.     EmptyParam, EmptyParam, EmptyParam, EmptyParam)
  87. end;
  88.  
  89. procedure TForm1.btnEasterEggClick(Sender: TObject);
  90. var
  91.   Target: {$ifdef DelphiLessThan3}Variant{$else}OleVariant{$endif};
  92. begin
  93.   Target := 'TheWCEE';
  94.   with TWebBrowser.Create(Self) do
  95.     try
  96.       Navigate('res://shdocvw.dll/wcee.htm',
  97.         EmptyParam, Target, EmptyParam, EmptyParam)
  98.     finally
  99.       Free
  100.     end;
  101. end;
  102.  
  103. { Windows 98 Easter Egg Instructions
  104.  
  105.   Invoke the Date/Time Properties applet from Control Panel.
  106.   This can be done by invoking Control Panel first, then
  107.   locating the relevant icon and double-clicking it.
  108.   You can also double-click the Clock in your task bar's
  109.   system tray. Alternatively, run one of these command-lines:
  110.  
  111.     COMMAND DATE/TIME
  112.     COMMAND TIMEDATE.CPL
  113.  
  114.   Click on the Time Zone tab
  115.   The next bit relies on some geography knowledge.
  116.   Hold down the Ctrl key and drag Memphis, Egypt and
  117.   drop it on Memphis, Tennessee.
  118.   Now hold down the Ctrl key and drag Memphis, Tennessee and
  119.   drop it on Seattle, USA
  120.  
  121.   If you got the right locations, a window will appear with
  122.   various pictures that come and go, and the credits list
  123.   will scroll by.
  124.  
  125.   There is a soundtrack as well, so turn your speakers up.
  126.  
  127.   You can circumvent all this trickery by making a new
  128.   shortcut on your Windows98 desktop. Make a shortcut with
  129.   a command-line of:
  130.  
  131.     "C:\Windows\Application Data\Microsoft\Welcome\WelData.Exe" You_are_a_real_rascal
  132.  
  133.   Make sure you go back to the properties for this shortcut
  134.   (right-click and choose properties) and set the Run: option
  135.   to say Minimized.
  136.  
  137.   The soundtrack to this Easter Egg is the file
  138.   C:\Windows\Application Data\Microsoft\Welcome\Welcom98.Wav }
  139. procedure TForm1.btnWin98Click(Sender: TObject);
  140. var
  141.   WinDir: array[0..MAX_PATH-1] of Char;
  142.   CmdLine: String;
  143. const
  144.   RelPath = '\Application Data\Microsoft\Welcome\';
  145.   AppName = 'WELDATA.EXE';
  146.   AppParam = 'You_are_a_real_rascal';
  147. begin
  148.   GetWindowsDirectory(WinDir, MAX_PATH);
  149.   CmdLine := Format('"%s%s%s" %s', [WinDir, RelPath, AppName, AppParam]);
  150.   WinExec(PChar(CmdLine), SW_SHOWMINNOACTIVE);
  151. end;
  152.  
  153. {$ifdef DelphiLessThan4}
  154. initialization
  155.   TVarData(EmptyParam).VType := varError;
  156.   TVarData(EmptyParam).VError := DISP_E_PARAMNOTFOUND
  157. {$endif}
  158. end.
  159.